﻿import 'package:get/get.dart';
import 'package:getx_scaffold/common/utils/toast_util.dart';
import 'package:azring/core/repository/default_api.dart';

class FeedbackDetailLogic extends GetxController {
  final feedbackDetail = Rxn<Map<String, dynamic>>();
  final isLoading = false.obs;
  late String feedbackId;

  @override
  void onInit() {
    super.onInit();
    feedbackId = Get.arguments['id'] ?? '';
    if (feedbackId.isNotEmpty) {
      loadFeedbackDetail();
    }
  }

  /// 加载反馈详情
  Future<void> loadFeedbackDetail() async {
    isLoading.value = true;
    try {
      final result = await DefaultApi().queryFeedbackGet<Map<String, dynamic>>(
        id: feedbackId,
      );

      if (result != null) {
        feedbackDetail.value = result;
      }
    } catch (e) {
      Toast.show('加载失败：${e.toString()}');
    } finally {
      isLoading.value = false;
    }
  }
}
